/*
 * Copyright (c) 2024 Huawei Technologies Co.,Ltd.
 *
 * openGauss is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *
 * http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 * -------------------------------------------------------------------------
 *
 * htap_global.h
 *
 * IDENTIFICATION
 * src/include/storage/htap/htap_global.h
 *
 * -------------------------------------------------------------------------
 */

#ifndef HTAP_GLOBAL_H
#define HTAP_GLOBAL_H

#include "global.h"

namespace htap {

/**
 * @enum Return code.
 */
enum RC : int {
    /** @var Denotes success. */
    HTAP_RC_OK,

    /** @var Denotes failure. */
    HTAP_RC_ERROR,

    HTAP_RC_OOM,
    HTAP_RC_INVALID_CFG,
    HTAP_RC_INVALID_ARG,
    HTAP_RC_SYSTEM_FAILURE,
    HTAP_RC_INTERNAL_ERROR,
    HTAP_RC_INVALID_STATE,
    HTAP_RC_EVENT_DISCARDED,
    HTAP_RC_TABLE_NOT_FOUND,
    HTAP_RC_INVALID,
    HTAP_RC_RESOURCE_LIMIT,

    HTAP_RC_MAX_VALUE
};

/**
 * @brief Converts return code to string value.
 * @param rc The return code.
 * @return The string representation of the return code.
 */
extern const char *RcToString(RC rc);

extern RC ToHTAPRc(MOT::RC rc);
} // namespace htap


#define HTAP_NO_ERROR hatp::HTAP_RC_OK
#define HTAP_ERROR_OOM htap::HTAP_RC_OOM
#define HTAP_ERROR_INVALID_CFG htap::HTAP_RC_INVALID_CFG
#define HTAP_ERROR_INVALID_ARG htap::HTAP_RC_INVALID_ARG
#define HTAP_ERROR_SYSTEM_FAILURE htap::HTAP_RC_SYSTEM_FAILURE
#define HTAP_ERROR_INTERNAL htap::HTAP_RC_INTERNAL_ERROR
#define HTAP_ERROR_INVALID_STATE htap::HTAP_RC_INVALID_STATE
#define HTAP_ERROR_EVENT_DISCARDED htap::HTAP_RC_EVENT_DISCARDED
#define HTAP_ERROR_TABLE_NOT_FOUND htap::HTAP_RC_TABLE_NOT_FOUND
#define HTAP_ERROR_RESOURCE_LIMIT htap::HTAP_RC_RESOURCE_LIMIT

#endif /* HTAP_GLOBAL_H */